<%@ page import="com.coolH.entity.Student" %>
<%--
  Created by IntelliJ IDEA.
  User: hbl
  Date: 2017/6/15
  Time: 13:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<html>
<head>
    <title>资料共享</title>
  <link href="/resources/css/hesder.css" rel="stylesheet">
  <script src="/resources/js/jquery-2.1.0.js"></script>
  <style>
    .inform{
      width: 100%;
      height: 60px;
      border: none;
      border-bottom: 1px solid gainsboro;
      line-height: 60PX;
    }
    .inform .file{
      float: left;
      margin-left: 20PX;
    }
    .inform .us{
      float: right;
      width: 300px;
      text-align: left;
    }
  </style>
</head>
<body>
<%--<c:forEach items="${student}" var="student">--%>
  <%--<p>${student.username} </p>--%>
<%--</c:forEach>--%>
<div id="header">
  <div><a href="../../index.jsp">首页</a></div><div>社区</div><div>资料共享</div><div><a href="http://localhost:8080/Student/getOwn">个人中心</a></div>
</div>
<div align="center">
  <script>

     function  call_your_function(userid){
       $.ajax("http://localhost:8080/Image/getByFile", {
         type: "get",
         data: {
            'userId':userid
         },
         success: function (data) {
           console.log(data);
           var dataObj = eval('(' + data + ')');
           var arr = dataObj.imgurl.split("\\");
           var src = "http://localhost:8080/resources/" + arr[arr.length - 2] + "/" + arr[arr.length - 1];
           console.log("?????????????????????" + src)
           setBg(src);
         },
         error: function () {
           alert(0)
         }
       })
       function setBg(src){
         console.log(">>>>>>>>>>>>>"+src)
         $(".head").attr("src",src)
       }
     }
  </script>


  <c:forEach items="${pages}" var="files">
    <script> call_your_function(${files.userid}) ; </script>
       <div class="inform"><div class="file">${files.filename} <a href="${files.fileurl}" download="${file.filename}">点击下载</a></div> <div class="us">贡献者：<img class="head" style="width: 30px ;height: 30px; border-radius: 50px" src="<%=request.getContextPath()%>/resources/files/USER-head.png">${student.username} </div> </div>
  </c:forEach>

  <font size="2">共 ${page.totalPageCount} 页</font> <font size="2">第
  ${page.pageNow} 页</font> <a href="pager?pageNow=1">首页</a>
  <c:choose>
    <c:when test="${page.pageNow - 1 > 0}">
      <a href="pager?pageNow=${page.pageNow - 1}">上一页</a>
    </c:when>
    <c:when test="${page.pageNow - 1 <= 0}">
      <a href="pager?pageNow=1">上一页</a>
    </c:when>
  </c:choose>
  <c:choose>
    <c:when test="${page.totalPageCount==0}">
      <a href="pager?pageNow=${page.pageNow}">下一页</a>
    </c:when>
    <c:when test="${page.pageNow + 1 < page.totalPageCount}">
      <a href="pager?pageNow=${page.pageNow + 1}">下一页</a>
    </c:when>
    <c:when test="${page.pageNow + 1 >= page.totalPageCount}">
      <a href="pager?pageNow=${page.totalPageCount}">下一页</a>
    </c:when>
  </c:choose>
  <c:choose>
    <c:when test="${page.totalPageCount==0}">
      <a href="pager?pageNow=${page.pageNow}">尾页</a>
    </c:when>
    <c:otherwise>
      <a href="pager?pageNow=${page.totalPageCount}">尾页</a>
    </c:otherwise>
  </c:choose>
</div>


</body>
</html>
